//
//  WWXCardViewController.m
//  IMChat
//
//  Created by Admin on 2021/7/14.
//  Copyright © 2021年 TeamOne. All rights reserved.
//

#import "WWXCardViewController.h"
#import "WWXUser.h"
#import "TOConversationViewController.h"

@interface WWXCardViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *headIV;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *idLabel;
@property (weak, nonatomic) IBOutlet UITableView *moreTV;


@end

@implementation WWXCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.nameLabel.text = self.User.userName;
    self.idLabel.text = self.User.userId;

    //设置tv
    self.moreTV.dataSource = self;
    self.moreTV.delegate = self;
}

#pragma mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    switch (section) {
        case 0:
            return 2;
        case 1:
            return 2;
        case 2:
            return 2;
        default:
            return -1;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"备注和标签";
        }
        if (indexPath.row == 1) {
            cell.textLabel.text = @"朋友权限";
        }
    }else if(indexPath.section == 1){
        if (indexPath.row == 0) {
            cell.textLabel.text = @"朋友圈";
        }
        if (indexPath.row == 1) {
            cell.textLabel.text = @"更多信息";
        }
    }else if(indexPath.section == 2){
        if (indexPath.row == 0) {
            cell.textLabel.text = @"发消息";
        }
        if (indexPath.row == 1) {
            cell.textLabel.text = @"音视频通话";
        }
    }
    return cell;
}

#pragma mark - UITableViewDelegate
//选择事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            
        }
        if (indexPath.row == 1) {
            
        }
    }else if(indexPath.section == 1){
        if (indexPath.row == 0) {
            
        }
        if (indexPath.row == 1) {
            
        }
    }else if(indexPath.section == 2){
        if (indexPath.row == 0) {
            TOConversationViewController *conversationVC = [[TOConversationViewController alloc] init];
            conversationVC.conversationType = ConversationType_PRIVATE;
            conversationVC.targetId = self.User.userId;
            
            // 隐藏底部tarbar
            self.tabBarController.tabBar.hidden = YES;
            
            [self.navigationController pushViewController:conversationVC animated:YES];

        }
        if (indexPath.row == 1) {
           
        }
    }
}


+(instancetype)initWithUser:(WWXUser *)User{
    WWXCardViewController *card = [[self alloc] init];
    card.User = User;
    return card;
}

@end
